package com.fhsk.file.manager.config;

import com.fhsk.file.business.common.JwtUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

public class MyCredentialsMatcher extends SimpleCredentialsMatcher
{
    @Override
    public boolean doCredentialsMatch(AuthenticationToken authenticationToken, AuthenticationInfo info)
    {
        String token = (String) authenticationToken.getCredentials();// 校验token有效性
        String username = JwtUtil.getUserName(token);
        return StringUtils.isNotBlank(username);
    }
}
